FROM busybox as builder
# 工作目录
WORKDIR /tmp
# 构建参数
ARG ghaddr=http://github.com tag=0.44.0 type=s
# 开始构建
RUN export TARGETARCH=$(uname -m|sed s/aarch64/arm64/g|sed s/armv7l/arm/g|sed s/x86_64/amd64/g) && \
    echo "downloading ${ghaddr}/fatedier/frp/releases/download/v${tag}/frp_${tag}_linux_${TARGETARCH}.tar.gz" && \
    wget -O- "${ghaddr}/fatedier/frp/releases/download/v${tag}/frp_${tag}_linux_${TARGETARCH}.tar.gz" | tar -xz "frp_${tag}_linux_${TARGETARCH}"
RUN mv "/tmp/frp_${tag}_linux_$(uname -m|sed s/aarch64/arm64/g|sed s/armv7l/arm/g|sed s/x86_64/amd64/g)/frp${type}" /tmp/frp
# 准备打包
FROM scratch
# 主程序
COPY --from=builder /tmp/frp /frp
# 配置文件
ADD ./cfg /cfg
# 默认变量
ENV server_addr=0.0.0.0 \
    server_port=7000 \
    protocol=tcp \
    log_level=info \
    disable_log_color=false 
# 系统端口
EXPOSE 7000/tcp 7000/udp 7001/udp 7500/tcp
# 存储配置
VOLUME [ "/cfg" ]
# 启动参数
ENTRYPOINT [ "/frp" ]
CMD [ "-c","/cfg/cfg.ini" ]